package com.framework.exception.common;

import lombok.Getter;
import lombok.Setter;

/**
 * 封装统一的返回响应体
 */
@Getter
@Setter
public class R<T> {

    private Integer code;
    private String msg;
    private T data;

    public static <T> R<T> success(T data){
        R<T> r = new R<T>();
        r.setCode(200);
        r.setMsg("success");
        r.setData(data);
        return r;
    }
    public static <T> R<T> success(){
        R<T> r = new R<T>();
        r.setCode(200);
        r.setMsg("success");
        return r;
    }

    public static <T> R<T> error(Integer code, String msg){
        R<T> r = new R<T>();
        r.setCode(code);
        r.setMsg(msg);
        return r;
    }


}
